package com.chenwy.example;

//import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;

@SpringBootApplication
//启用Springfox swagger2
@EnableSwagger2
@EnableTransactionManagement
//@EnableJpaRepositories(basePackages={"com.chenwy.example.repository"})
//@MapperScan(basePackages = {"com.chenwy.example.dao"})
public class ExampleForFunApplication {

	public static void main(String[] args) {
		SpringApplication.run(ExampleForFunApplication.class, args);
		Stack<Character> stack = new Stack<Character>();
		String string = "(()[]{})";
		Map<Character,Character> map = new HashMap<Character,Character>();
		map.put(')', '(');
		map.put(']','[');
		map.put('}','{');
		for(int i = 0;i < string.length();i++){
			char character = string.charAt(i);
			if(!map.containsKey(character)){
				stack.push(string.charAt(i));
			}else if(map.get(character) == stack.peek()){
				stack.pop();
			}
		}
		System.out.println(stack.size());
		if(stack.isEmpty()) System.out.println(true);
		else System.out.println(false);
	}

	/**
	 *
	 * @param context
	 * @return
	 */
	@Bean
	public CommandLineRunner commandLineRunner(ApplicationContext context){
		return args -> {
			System.out.println("输出=================Spring Boot中注入的bean");
			String [] beans = context.getBeanDefinitionNames();
			Arrays.asList(beans).forEach(System.out::println);
			System.out.println("结束=================");
		};
	}

}
